package calculator.controller;/*
 * @author     ：zhangbo
 * @date       ：Created in 2021/5/22 11:50
 * @description：实现了ActionListener接口，负责处理ActionEvent事件的共用方法。
 * @modified By：zhangbo
 * @version:     $
 */

import calculator.view.CalculatorWindows;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

public class HandleEvent implements ActionListener {

    CalculatorWindows window;

    HandleEvent(CalculatorWindows window) {
        this.window = window;
    }

    public void showMess() {
        window.resultShow.setText(" = " + get(window.computer.getResult()));
        window.showTempResult.setText(get(window.computer.getTempResult()) + "");
        window.showOperator.setText(" " + window.computer.getOperator() + "");
        window.showDataItem.setText(" " + get(window.computer.computerDataItem()));
    }

    public String get(double r) {
        String s = "";
        Double d = new Double(r);
        long n = d.longValue();
        if (Math.abs(r - n) > 0)
            s = "" + r;
        else
            s = "" + n;
        return s;
    }

    @Override
    public void actionPerformed(ActionEvent e) {

    }
}
